package com.ktgj.train.controller;

import com.ktgj.common.core.annotation.Excel;
import com.ktgj.common.core.domain.R;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.web.page.TableDataInfo;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.api.RemoteCustomerService;
import com.ktgj.customer.api.domain.Customer;
import com.ktgj.train.domain.TrainContacts;
import com.ktgj.train.domain.TrainCountry;
import com.ktgj.train.service.ITrainContactsService;
import com.ktgj.train.service.ITrainCountryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * 国家Controller
 * 
 * @author ruoyi
 * @date 2021-11-29
 */
@ControllerAdvice
@RestController
@RequestMapping("/trainContacts")
public class TrainContactsController extends BaseController
{
    @Autowired
    private ITrainContactsService trainContactsService;

    @Autowired
    private RemoteCustomerService remoteCustomerService;

    /**
     * 添加乘车人
     * */
//    @PostMapping("/addPassengers")
//    public AjaxResult addPassengers(HttpServletRequest request, @RequestBody(required = false) Map<String, Object> map){
//        String gatValidDateEnd = null;
//        String sex = null;
//        String birthday = null;
//        String country = null;
//        if (map.get("gatValidDateEnd") != null){
//            gatValidDateEnd = map.get("gatValidDateEnd").toString();
//        }
//        if (map.get("sex") != null){
//            sex = map.get("sex").toString();
//        }
//        if (map.get("birthday") != null){
//            birthday = map.get("birthday").toString();
//        }
//        if (map.get("country") != null){
//            country = map.get("country").toString();
//        }
//        String token = request.getHeader("token");
//        R<Customer> customer = remoteCustomerService.getLoginCustomerByToken(token);
//        Long customerId = customer.getData().getCustomerId();
//        TrainContacts trainContacts = new TrainContacts();
//        trainContacts.setName(map.get("name").toString());
//        trainContacts.setSex(sex);
//        trainContacts.setBirthday(birthday);
//        trainContacts.setCountry(country);
//        trainContacts.setIdentyType(map.get("identyType").toString());
//        trainContacts.setIdenty(map.get("identy").toString());
//        trainContacts.setPersonType(map.get("personType").toString());
//        trainContacts.setPhone(map.get("phone").toString());
//        trainContacts.setCustomerId(customerId);
//        trainContacts.setGatValidDateEnd(gatValidDateEnd);
//        return toAjax(trainContactsService.insertTrainContacts(trainContacts));
//    }
}
